#include "SentenceIndexerBuilder.h"

#include "ScriptCompiler/ScriptFileContext.h"
#include "ScriptCompiler/AST/SentenceIndexerNode.h"

#include "ScriptCompiler/ASTBuilder/ArgumentsBuilder.h"

CSentenceIndexerBuilder::CSentenceIndexerBuilder(std::shared_ptr<CScriptFileContext> InContext)
{
    Context = InContext;
    Result= std::make_shared<CSentenceIndexerNode>(InContext);
}

bool CSentenceIndexerBuilder::ReadCurentToken()
{
    //create argument builder
    auto ArgumentBuilder = std::make_shared<CArgumentsBuilder>(Context);
    ArgumentBuilder->LeftBracketType = EScriptTokenType::LeftBracket;
    ArgumentBuilder->RightBracketType = EScriptTokenType::RightBracket;

    //read arguments
    if(!ArgumentBuilder->ReadCurentToken())
    {
        return false;
    }

    Result->Indexers = ArgumentBuilder->Result;
    Result->LeftBracket = ArgumentBuilder->LeftBracket;
    Result->RightBracket = ArgumentBuilder->RightBracket;

    return true;
}
